home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: tangaroa@werple.net.au (Simon Crase)
- Newsgroups: comp.std.c++
- Subject: Re: Const class member
- Date: 31 Mar 1996 02:20:21 GMT
- Organization: Werple Internet, Melbourne
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <4jkjuq$t4h@eplet.mira.net.au>
- References: <4jgpqa$t09@nntp.interaccess.com>
- NNTP-Posting-Host: taumet.eng.sun.com
- X-Nntp-Posting-Host: werplez.mira.net.au
- X-Newsreader: TIN [version 1.2 PL2]
- Content-Length: 1840
- Originator: clamage@taumet
-
- Brian V. McGroarty (brianmcg@interaccess.com) wrote:
- : Is this legal? Borland and Microsoft compilers will accept the following:
-
- : class AnyClass
- : {
- : const int constInt;
- : }
-
- : The Borland compiler complains about the uninitialized constant, whereas
- : the Microsoft compiler does not. If a constructor is present, both will
- : complain that the constant isn't initialized in the constructor, however
- : neither will allow you to assign a value in the constructor by simply
- : specifying "constInt= some value". I have also attempted to initialize in
- Have you tried:
- AnyClass::AnyClass
- : constInt(42)
- {
- }
- The geenral idea seems to be to disallow any piece of code that assigns
- a value using constInt=....
- : a global variable "int AnyClass::constInt", to determine whether static
- : somehow became implicit -- still no go. If this is legal, how is the value
- : initialized?
-
- : Would compilers stand a better chance of optimizing given the above via
- : constant propogation through inlined (member only?) functions applied to a
- : hard-coded instance of the object, or would it just be to help prevent
- : programmers' error?
-
- : ---
- : Brian Valters McGroarty -- brianmcg@bix.com
- : phone/fax (847) 439-7714
- : ---
- : [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- : [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- : [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- : [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- : [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-
- --
- Simon A. Crase Emerson & Crase Consultants - ++61-3-9592-1764
- Artificial Intelligence, Graphical User Interfaces, C++,
- Object Oriented Design, Microsoft Windows Applications
- s.crase@ieee.org = tangaroa@werple.net.au
-
-
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-